package com.itheima.mapper;


import com.github.pagehelper.Page;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.vo.CheckGroupVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckGroupMapper {
    /**
     * 添加检查组
     * @param checkGroup
     */
    @Insert("insert into t_checkgroup (code,name,sex,helpCode,remark,attention) " +
            "values (#{code},#{name},#{sex},#{helpCode},#{remark},#{attention})")
    void add(CheckGroup checkGroup);

    /**
     * 删除检查组
     * @param id
     * @return
     */
    @Delete("delete from t_checkgroup where id = #{id}")
    void deleteById(Integer id);

    /**
     * 添加检查组和检查项的关联关系
     * @param id
     * @param checkitemId
     */
    @Insert("insert into t_checkgroup_checkitem(checkgroup_id,checkitem_id) values(#{id},#{checkitemId})")
    void addCheckGroupAndCheckItem(Integer id, Integer checkitemId);

    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    Page<CheckGroupVO> findPage(QueryPageBean queryPageBean);

    /**
     *  根据根据套餐id查询关联的检查项id
     * @param  setmealId
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where checkgroup_id = #{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);

    /**
     * 根据检查组id删除检查组和检查项的关联关系
     * @param id
     */
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    void deleteCheckGroupAndCheckItem(Integer id);

    /**
     * 修改检查组
     * @param checkGroup
     * @return
     */
    void edit(CheckGroup checkGroup);

    /**
     * 查询全部检查组
     * @return
     */
    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();

    /**
     * 根据检查组id查询检查组信息
     * @param id
     * @return
     */
    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);
}
